/** 配置并链接MongoDB **/
var mongoose = require('mongoose');

// mongoose.connect(uri);
// 链接数据库
var url = 'mongodb://localhost/chat';
mongoose.connect(url, {
  useNewUrlParser: true
})


/** 创建公共聊天schema **/
var ChatSchema = new mongoose.Schema({
  msg: String,
  time: String,
  ip: String,
  chatId: String,
  username: String,
  usericon: String,
  myCode: Number

});
mongoose.model('Chat', ChatSchema);


/** 创建私聊schema **/
var PrivateSchema = new mongoose.Schema({
  status: String,
  time: String,
  ip: String,
  myCode: Number
});
mongoose.model('Private', PrivateSchema);


/** 创建 用户名注册 Schema、创建Model **/
var UserSchema = new mongoose.Schema({
  time: String,
  ip: String,
  username: String,
  password: String,
  usericon: String,
  role: String
});
mongoose.model('Users', UserSchema);


/** 创建 患者 Schema、创建Model **/
var DataSchema = new mongoose.Schema({
  ip: String,
  name: String,
  createName: String,
  age: String,
  sex: String,
  websource: String,
  zhenduan: String,
  zxdf: String,
  phone: String,
  doctor: String,
  region: String,
  date: String,
  qq: String,
  msgsource: String,
  weixin: String,
  urgency: String,
  buwei: String,
  createTime: String,
  lastTime: String,
  zz: String,
  beianren: String,
  status: String,
  regionKey: String,
  textarea: String
});
mongoose.model('Patient', DataSchema);


// 员工管理
var StaffSchema = new mongoose.Schema({
  // 创建人ip
  ip: String,
  // 创建人
  createName: String,
  // 创建时间
  createTime: String,
  // 最后修改时间
  lastTime: String,
  // 员工名称
  staffName: String,
  // 年龄
  age: String,
  // 性别
  sex: String,
  // 电话
  phone: String,
  // 生日
  shengri: String,
  // 血型
  xuexing: String,
  // 星座
  xingzuo: String,
  // 身高
  height: String,
  // 体重(KG)
  weight: String,
  // 健康状况
  jiankangzhuangkuang: String,
  // 疾病史
  bingli: String,
  // 最高学历
  xueli: String,
  // 毕业院校
  biyeyuanxiao: String,
  // 所学专业
  zhuanye: String,
  // 特长
  techang: String,
  // 爱好
  aihao: String,
  // 身份证号
  shenfenzheng: String,
  // 民族
  minzu: String,
  // 政治面貌
  zhengzhimianmao: String,
  // 籍贯
  jiguan: String,
  jiguantext: String,
  // 现住址
  zhuzhi: String,
  // 住房
  zhufang: String,
  // 婚育
  hunyu: String,
  // 驾照
  jiazhao: String,
  // 护照
  huzhao: String,
  // 退伍证
  tuiwuzheng: String,
  // 岗位
  gangwei: String,
  // 职务
  zhiwu: String,
  // 入职日期
  ruzhi: String,
  // 离职日期
  lizhi: String,
  // 关系
  guanxi: String,
  // 姓名
  xingming: String,
  // 工作学习单位
  danwei: String,
  // 职位职务
  zhiwei: String,
  // 联系电话
  dianhua: String,
  // 出生日期
  chusheng: String,
  // 入职状态
  status: String,
  // 头像地址
  imgUrl: String
});
mongoose.model('Staff', StaffSchema);
